//
//  GroupViewController.m
//  Conference
//
//  Created by Xiang He on 12-11-15.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "GroupViewController.h"
#import "ConfNoticeViewController.h"
#import "ScheduleMeetingViewController.h"
#import "ConfNoticeViewController.h"
#import "AirPortViewController.h"
#import "NewsViewController.h"
#import "CredentialsViewController.h"
#import "ShakeViewController.h"
#import "EleSpeechViewController.h"
#import "ChatViewController.h"
#import "HotelViewController.h"
#import "PlaceViewController.h"
#import "TaskAssignViewController.h"
#import "Constant.h"

@interface GroupViewController ()

@end

@implementation GroupViewController
@synthesize baseView;
@synthesize btn_back;
@synthesize btn_menu;
@synthesize btn_notice;
@synthesize btn_schedule;
@synthesize btn_news;
@synthesize btn_passes;
@synthesize type;
@synthesize lab_title;

@synthesize currentViewController;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
   
    [self SwitchActivity:self.type];
   
   
    
}

- (void)viewDidUnload
{
    [self setBaseView:nil];
    [self setBtn_back:nil];

    [self setBtn_menu:nil];
    [self setBtn_notice:nil];
    [self setBtn_schedule:nil];
    [self setBtn_passes:nil];
    [self setBtn_news:nil];
    
    [self setCurrentViewController:nil];
    [self setLab_title:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)dealloc {
    [baseView release];
    [btn_back release];

    [btn_menu release];
    [btn_notice release];
    [btn_schedule release];
    [btn_passes release];
    [btn_news release];
    
    [currentViewController release];
    [lab_title release];
    [super dealloc];
}
- (IBAction)backAction:(id)sender {
    
    [self.navigationController popViewControllerAnimated:YES];
}


- (IBAction)menuAction:(id)sender {

     [self.navigationController popViewControllerAnimated:YES];
}


- (IBAction)scheduleMeetingAction:(id)sender {
    
    [self switchImg];
    [self.btn_schedule setSelected:YES];
    
   
    [self SwitchActivity:[[Constant getInstance] CONTROLLER_SCHEDULE]];   
    
    
}

- (IBAction)confNoticeAction:(id)sender {
    
    [self switchImg];
    [self.btn_notice setSelected:YES];
    
    [self SwitchActivity:[[Constant getInstance] CONTROLLER_ALARM]];    
}


-(void) SwitchActivity:(int) flag{
    
    if(self.currentViewController !=nil) {  
        [self.currentViewController.view removeFromSuperview];
        [self.currentViewController removeFromParentViewController];
    }
        
    
    if(flag==[[Constant getInstance] CONTROLLER_ALARM]){
        
        self.lab_title.text=@"大会通知";
        ConfNoticeViewController *mConfNoticeViewController =[[ConfNoticeViewController alloc] initWithNibName:@"ConfNoticeViewController" bundle:nil];
        
        self.currentViewController=mConfNoticeViewController;
        
        [mConfNoticeViewController release];
   
    }else if(flag==[[Constant getInstance]CONTROLLER_SCHEDULE]){
        self.lab_title.text=@"会议日程";
        ScheduleMeetingViewController *mScheduleMeetingViewController=[[ScheduleMeetingViewController alloc]initWithNibName:@"ScheduleMeetingViewController" bundle:nil];
        
        self.currentViewController=mScheduleMeetingViewController;
        
        [mScheduleMeetingViewController release];
    
    }else if (flag==[[Constant getInstance]CONTROLLER_NEWS]){
        self.lab_title.text=@"会议新闻";
        NewsViewController  *mNewsViewController=[[NewsViewController alloc]initWithNibName:@"NewsViewController" bundle:nil];
        
        self.currentViewController=mNewsViewController;
        
        [mNewsViewController release];
        
        
    }else if (flag==[[Constant getInstance]CONTROLLER_HOTEL]){
        self.lab_title.text=@"酒店预定";
        HotelViewController  *mHotelViewController=[[HotelViewController alloc]initWithNibName:@"HotelViewController" bundle:nil];
        
        self.currentViewController=mHotelViewController;
        
        [mHotelViewController release];  
        
        
    }else if (flag==[[Constant getInstance]CONTROLLER_AIRPORT]){
        self.lab_title.text=@"接送机安排";
        AirPortViewController *mAirPortViewController=[[AirPortViewController alloc]initWithNibName:@"AirPortViewController" bundle:nil];
        self.currentViewController=mAirPortViewController;
        [mAirPortViewController release];
        
    }else if (flag==[[Constant getInstance]CONTROLLER_CREDENTIALS]){
        self.lab_title.text=@"电子参会证";
        CredentialsViewController *mCredentialsViewController=[[CredentialsViewController alloc]initWithNibName:@"CredentialsViewController" bundle:nil];
        self.currentViewController=mCredentialsViewController;
        
        [mCredentialsViewController release];
       
    }else if (flag==[[Constant getInstance] CONTROLLER_PALCE]){
        self.lab_title.text=@"会场信息";
        PlaceViewController *mPlaceViewController=[[PlaceViewController alloc]initWithNibName:@"PlaceViewController" bundle:nil];
        self.currentViewController=mPlaceViewController;
        
        [mPlaceViewController release];
        
    }else if (flag==[[Constant getInstance] CONTROLLER_ELESPEECH]){
        self.lab_title.text=@"电子演讲稿";
        EleSpeechViewController *mEleSpeechViewController=[[EleSpeechViewController alloc]initWithNibName:@"EleSpeechViewController" bundle:nil];
        self.currentViewController=mEleSpeechViewController;
        
        [mEleSpeechViewController release];
        
    }else if (flag==[[Constant getInstance] CONTROLLER_TASKASSIGN]){
        self.lab_title.text=@"活动安排";
         TaskAssignViewController *mTaskAssignViewController=[[TaskAssignViewController alloc]initWithNibName:@"TaskAssignViewController" bundle:nil];
        self.currentViewController=mTaskAssignViewController;
        
        [mTaskAssignViewController release];
        
    }
    
    [self addChildViewController:currentViewController];
    [self.baseView addSubview:self.currentViewController.view];
   

}

- (IBAction)electrPassesAction:(id)sender {

    [self switchImg];
    [self.btn_passes setSelected:YES];
    [self SwitchActivity:[[Constant getInstance] CONTROLLER_CREDENTIALS]];

}

- (IBAction)newsAction:(id)sender {

    [self switchImg];
    [self.btn_news setSelected:YES];
    [self SwitchActivity:[[Constant getInstance] CONTROLLER_NEWS]];
}



-(void) switchImg{
    
    [self.btn_menu setSelected:NO];
    [self.btn_notice setSelected:NO];
    [self.btn_schedule setSelected:NO];
    [self.btn_news setSelected:NO];
    [self.btn_passes setSelected:NO];
    
}



@end
